package demo;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

/**
 * @Author: wangliuyang
 * @Date: 2021/8/4 19:51
 * @Description: 位运算
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        System.out.println(-3 % 10);
//        int i = 1;
//        System.out.println(1 << 1);
        System.out.println(-3 >> 1);
        System.out.println(-1 << 1);
        System.out.println(-3 >>> 1);
//        System.out.println(~ 1);
//        System.out.println(-1 ^ -2);
//        String s = new String("abc");
//        Integer a = 1;
//        Character b = 'A';
//        System.out.println(b+0);
//        ArrayList<Integer> list = new ArrayList<>();
//        List<Integer> collect = list.stream().filter(
//                (num) -> {
//                    System.out.println("111");
//                    return num == 1;
//                }
//        ).collect(Collectors.toList());
//        System.out.println(collect.size());
//        System.out.println("a".hashCode());
//        ReentrantLock lock = new ReentrantLock();
//
//
//        Thread thread = new Thread(() -> {
//            synchronized (demo1.class) {
//                System.out.println(1);
//                LockSupport.park();
//                throw new RuntimeException();
//            }
//        });
//        thread.start();
//        synchronized (demo1.class){
//            System.out.println(1);
//            LockSupport.park();
//            System.out.println(2);
//        }
//        TimeUnit.SECONDS.sleep(2);
//        synchronized (demo1.class){
//            LockSupport.unpark(thread);
//            System.out.println(1);
//            demo1.class.notifyAll();
//            demo1.class.wait();
//            System.out.println(2);
//        }
//        String name = "zhangsan";
//        AtomicReference<String> nameref= new AtomicReference<>(name);
//        String lisi = nameref.getAndSet("lisi");
//        System.out.println(nameref.get());
//        System.out.println(name);
        ScheduledThreadPoolExecutor sc = new ScheduledThreadPoolExecutor(3);
        ScheduledFuture<Integer> scheduledFuture = sc.schedule(() -> {
            System.out.println(111111);
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            throw new RuntimeException("timeout");
        }, 1000, TimeUnit.MILLISECONDS);
//        Integer a = scheduledFuture.get();
//        System.out.println(a.getClass().getName());
        sc.scheduleWithFixedDelay(() -> {
            System.out.println( 222222);
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },1000,5000,TimeUnit.MILLISECONDS);
    }
}
